<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>骨医快线</title>
    <link href="../css/mui.plus.css" rel="stylesheet"/>
    <style>
    	.oe-info-mine span{
    		padding: 10px;
    		font-size: 14px;
    		color: #999;
    	}
    	.pat-img-wrap {
			margin: 20px auto; 
    		width: 25vw;
    		height: 25vw;
    		border-radius: 50px;
    	}
    	.mui-icon>img {
		    width: 20px;
    		margin-right: 5px;
    	}
    </style>
</head>
<body style="background: #F5F5F5;">
	<div class="mui-content mui-scroll-wrapper oe-home oe-mine" id="refreshContainer">
		<div class="mui-scroll">
			<div class="oe-info-mine">
				<div id="wrapAvt" class="pat-img-wrap">
					<img id="btnAvatar" src="../images/avatar-default.png" alt=""  style="border-radius: 100px;height: 100%;"/>
				</div>
				<p style="color: #000;font-size: 20px;" id="namePanel">张医生</p>
				<span id="hosPanel">北京朝阳医院</span><span id="titlePanel">副主任医师</span>
			</div>
			
			<div class="oe-divide-block"></div>
			
			<ul class="mui-table-view" style="margin-top: 0;">
				<li id="my_info" class="mui-table-view-cell" data-page="info">
					<a class="mui-navigate-right">
						<span class="mui-icon mui-pull-left">
							<img src="../images/mine/personal.png"/>
						</span>
						个人信息
					</a>
				</li>
			</ul>
			
			<div class="oe-divide-block"></div>
			
			<ul class="mui-table-view" >
				<!--<li class="mui-table-view-cell" data-page="integral/home">
					<a class="mui-navigate-right">
						<span class="mui-icon mui-pull-left">
							<img src="../images/mine/integral.png"/>
						</span>
						我的积分
					</a>
				</li>-->
				<li class="mui-table-view-cell" data-page="collection">
					<a class="mui-navigate-right">
						<span class="mui-icon mui-pull-left">
							<img src="../images/mine/collection.png"/>
						</span>
						我的收藏
					</a>
				</li>
			</ul>
			
			<div class="oe-divide-block"></div>
			
			<ul class="mui-table-view">
				<li class="mui-table-view-cell" data-page="feedback">
					<a class="mui-navigate-right">
						<span class="mui-icon mui-pull-left">
							<img src="../images/mine/feed_back.png"/>
						</span>
						意见反馈
					</a>
				</li>
				<li class="mui-table-view-cell" data-page="setting">
					<a class="mui-navigate-right">
						<span class="mui-icon mui-pull-left">
							<img src="../images/mine/setting.png"/>
						</span>
						设置
					</a>
				</li>
			</ul>
		</div>
	</div>
	
	<script src="../js/mui.min.js"></script>
	<script src="../js/app.js"></script>
	<script src="../js/lib/moxie.js"></script>
    <script src="../js/lib/plupload.dev.js"></script>
	<script src="../js/lib/qiniu.min.js"></script>
	<script type="text/javascript" charset="utf-8">
      	(function($, doc){
      		var nameP = document.getElementById("namePanel"),
      			hosP = document.getElementById("hosPanel"),
      			titleP = document.getElementById("titlePanel"),
      			avatarP = document.getElementById("btnAvatar");
      		
      		function reload(){
      			nameP.innerHTML = app.storage.getUserInfo().dr_name || (app.storage.getUserInfo().dr_mobile == undefined ? '点击注册' : '水煮鱼');
	      		hosP.innerHTML = app.storage.getUserInfo().dr_hospital || '';
	      		titleP.innerHTML = app.storage.getUserInfo().dr_title || '';
	      		avatarP.src = app.storage.getUserInfo().dr_avatar_src || '../images/dr_avatar.png';
      		}
      		
      		reload();
			
			window.addEventListener('start', function(){
				reload();
			});
			
			$.init({
				pullRefresh : {
			    container:"#refreshContainer",//下拉刷新容器标识，querySelector能定位的css选择器均可，比如：id、.class等
			    down: {
			    	contentdown : '下拉可以刷新',
			    	contentover : '释放立即刷新',
			    	contentrefresh : '正在刷新...',
					callback: pulldownRefresh
				}
			  }
      		});
      		
      		
      		function pulldownRefresh(){
      			reload();
            	setTimeout(function(){
            		mui('#refreshContainer').pullRefresh().endPulldownToRefresh();
            		$.plusReady(function(){
            			plus.nativeUI.toast('更新成功');
            		});
            	},2000);
            };
             
      		var ls = app.utils.localS;
      		$.plusReady(function(){
				plus.webview.currentWebview().setStyle({scrollIndicator:'none'});
				
				var	mConll = document.querySelector('#my_collect'),
					mInfo = document.querySelector('#my_info');
				
				$('.mui-content').on('tap', '#my_info', function(){
					if(app.storage.getUserId() !== undefined){
						$.openWindow({
							url: 'mine/info.html',
							waiting: {
								autoShow: false
							}
						});
					}else {
						$.openWindow({
							url: 'login/login-main.html',
							waiting: {
								autoShow: false
							}
						});
					}
				});
				
				$('.mui-content').on('tap', 'li', function(){
					if(!this.dataset.page || this.dataset.page === 'info') return;
					$.openWindow({
						url: 'mine/'+ this.dataset.page + '.html',
						waiting: {
							autoShow: false 
						}
					})
				})
				 
				$('.mui-content').on('tap', '#namePanel', function(){
					if(this.innerHTML == '点击注册'){
						$.openWindow({
							url: 'login/login-main.html',
							waiting :{
								autoShow : false
							}
						});
					}
				});
				
      		});
      		
      		// ===================================================================================
      		// Qiniu 
      		
      		var updateObj;
      		var qnOp1 = {
					browse_button : 'btnAvatar', //必选参数,打开文件管理器的触发器 
					uptoken : 'ArjlNfgX9rDSZl1wMrr3PEyFG7O6v7OK9N1UGilS:9NRsiB5adL07-KcxqGThr8B4Gs4=:eyJzY29wZSI6Im9ydGhzcHJvZCIsImRlYWRsaW5lIjoxNDk2ODM4NTQ2fQ==', // uptoken 是上传凭证，由其他程序生成
					unique_names : false,              // 默认 false，key 为文件名。若开启该选项，JS-SDK 会为每个文件自动生成key（文件名）
					domain : '7xus80.com2.z0.glb.qiniucdn.com',     // bucket 域名，下载资源时用到，**必需**
					auto_start: true, 
					init : {
				        'FilesAdded': function(up, files) {
				        	var num = 0;
				            plupload.each(files, function(file) {
				            	num ++;
				            	if(num > 0){
				            		return;
				            	}
				            	// 文件添加进队列后,处理相关的事情
				            });
				        },
				        'BeforeUpload': function(up, file) {
				            // 每个文件上传前,处理相关的事情
				        },
				        'UploadProgress': function(up, file) {
			                // 每个文件上传时,处理相关的事情
				        },
				        'FileUploaded': function(up, file, info) {
				            // 每个文件上传成功后,处理相关的事情
							updateObj = {
				            	dr_id : app.storage.getUserId(),
				            	dr_avatar_src : JSON.parse(info).key
				            };
				        },
				        'Error': function(up, err, errTip) {
				               //上传出错时,处理相关的事情
				        },
				        'UploadComplete': function() {
				               //队列文件处理完毕后,处理相关的事情
				            app.net.post('doctors/update.json', updateObj,function(data){
				            	if(data && data.code == 100){
				            		app.storage.setUserInfo(data.data);
				            		document.getElementById("btnAvatar").src = data.data.dr_avatar_src;
				             		plus.nativeUI.toast('上传成功');
				            	}
				            });
				        },
				        'Key': function(up, file) {
				            // 若想在前端对每个文件的key进行个性化处理，可以配置该函数
				            // 该配置必须要在 unique_names: false , save_key: false 时才生效
							
				            var key = new Date().getTime();
				            // do something with key here
				            return key;
				        }
					}
				};
					
			Qiniu.uploader(qnOp1);
      	}(mui, document));
    </script>
</body>
</html>